package com.ruoyi.zhjd.laboratory.modules.groutingRecord.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//
//
//
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.zhjd.laboratory.modules.groutingRecord.entity.GroutingRecord;
import com.ruoyi.zhjd.laboratory.modules.groutingRecord.mapper.LGroutingRecordMapper;
import com.ruoyi.zhjd.laboratory.modules.groutingRecord.service.LGroutingRecordService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 压浆记录(GroutingRecord)表服务实现类
 *
 * @author makejava
 * @since 2023-07-12 14:59:13
 */
@AllArgsConstructor
@Service("groutingRecordService")
public class LGroutingRecordServiceImpl extends ServiceImpl<LGroutingRecordMapper, GroutingRecord> implements LGroutingRecordService {

//    @Autowired
//    private BaseServiceComponent baseServiceComponent;

    @Override
    public IPage<GroutingRecord> page(Map<String, Object> params) {
//        IPage<GroutingRecord> page = baseServiceComponent.getPage(params, GroutingRecord.class);
        return baseMapper.query(null, params);
    }

    /**
     * 查询
     *
     * @param id
     * @return
     */
    @Override
    public GroutingRecord getInfoById(String id) {
        return getById(id);
    }

    /**
     * 新增
     *
     * @param groutingRecord
     */
    @Override
    public void insertGroutingRecord(GroutingRecord groutingRecord) {
        groutingRecord.setId(IdWorker.get32UUID());
        //创建者
        LoginUser loginUser = LoginHelper.getLoginUser();
        groutingRecord.setCreateBy(ObjectUtils.isNotNull(loginUser) ? loginUser.getUserId() : null);
        //创建时间
        groutingRecord.setCreateTime(DateUtils.getNowDate());
        save(groutingRecord);
    }

    /**
     * 修改
     *
     * @param groutingRecord
     */
    @Override
    public void updateGroutingRecord(GroutingRecord groutingRecord) {
        //修改者
        LoginUser loginUser = LoginHelper.getLoginUser();
        groutingRecord.setUpdateBy(ObjectUtils.isNotNull(loginUser) ? loginUser.getUserId() : null);
        //修改时间
        groutingRecord.setUpdateTime(DateUtils.getNowDate());
        updateById(groutingRecord);
    }

    /**
     * 删除
     *
     * @param ids
     */
    @Override
    public void deleteByIds(List<String> ids) {
        removeByIds(ids);
    }
}

